from django.contrib import admin
from .models import NavCategory, Banner, CourseCategory

@admin.register(NavCategory)
class NavCategoryAdmin(admin.ModelAdmin):
    list_display = ['name', 'display_name', 'weight', 'is_active', 'theme_color', 'show_countdown']
    list_editable = ['weight', 'is_active', 'theme_color']
    search_fields = ['name', 'display_name']
    list_filter = ['is_active', 'show_countdown']

@admin.register(Banner)
class BannerAdmin(admin.ModelAdmin):
    list_display = ['title', 'link', 'image', 'is_show', 'weight', 'is_deleted', 'created_time']
    list_editable = ['is_show', 'weight', 'is_deleted']
    search_fields = ['title', 'note']
    list_filter = ['is_show', 'is_deleted']
    readonly_fields = ['created_time', 'updated_time']
    list_per_page = 20  # 每页显示的记录数

@admin.register(CourseCategory)
class CourseCategoryAdmin(admin.ModelAdmin):
    list_display = ['category_name', 'parent', 'level', 'description', 'created_at', 'updated_at']
    list_filter = ['level']
    search_fields = ['category_name', 'description']
    list_editable = ['level', 'parent']
